package drds.common.db.sql_mapping.dynamic_tag.tag_handler;

import drds.common.db.sql_mapping.dynamic_tag.sql_template.XmlMapperBuilder;
import drds.common.db.sql_mapping.dynamic_tag.tag.CompositeTag;
import drds.common.db.sql_mapping.dynamic_tag.tag.IfTag;
import drds.common.db.sql_mapping.dynamic_tag.tag.Tag;
import drds.common.db.sql_mapping.dynamic_tag.xml_node.XmlNode;

import java.util.List;

public class IfTagHandler implements TagHandler {
    private XmlMapperBuilder xmlMapperBuilder;

    public IfTagHandler(XmlMapperBuilder xmlMapperBuilder) {
        this.xmlMapperBuilder = xmlMapperBuilder;
    }

    @Override
    public void handleNode(XmlNode xmlNodeToHandle, List<Tag> tagList) {
        CompositeTag compositeNode = xmlMapperBuilder.parseTags(xmlNodeToHandle);
        String test = xmlNodeToHandle.getStringAttribute("test");
        IfTag ifTag = new IfTag(compositeNode, test);
        tagList.add(ifTag);
    }
}
